package com.minisoft.utils.thread;

import cn.hutool.core.util.RandomUtil;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.concurrent.*;

/**
 * @author JueSu
 * @description: 定时任务测试类
 * @date 2022/5/1 16:24
 */
@Slf4j
public class ScheduleTest {


    @Test
    public void test1() throws InterruptedException {
        ScheduleRetry.addTask(new Callable<Boolean>() {
            public Boolean call() throws Exception {
                int i = RandomUtil.randomInt(5);
                log.info("random i = " +i);
                return i == 3;
            }

            public String toString() {
                return "test";
            }
        },20,3);
        ScheduleRetry.addTask(new Callable<Boolean>() {
            public Boolean call() throws Exception {
                int i = RandomUtil.randomInt(5);
                log.info("random i = " +i);
                return i == 2;
            }

            public String toString() {
                return "test2";
            }
        },20,2);
        Thread.sleep(100000000);
    }
}
